#include <iostream>
#include "ControleDeSaisie.h"
#include <sstream>

ControleDeSaisie::ControleDeSaisie()
{
}
ControleDeSaisie::~ControleDeSaisie()
{
}
int ControleDeSaisie::VerifierInteger()
{
int Num;
bool gotValidInput = false;
 
while ( gotValidInput == false )
{	
      cin >> Num;
 
	if (cin.fail())
      {	cin.clear();
            cin.ignore();
            cout << "Verifier le numéro saisie!!!!                                        *" << endl;
      }
	else
      {	gotValidInput = true;
      } 
}
return Num;
}

long ControleDeSaisie::Verifierlong()
{
long Num;
bool gotValidInput = false;
 
while ( gotValidInput == false )
{     cin >> Num;
 
	if (cin.fail())
      {	cin.clear();
            cin.ignore();
            cout << "Verifier le numéro saisie!!!!                                        *" << endl;
      }
	else
      {	gotValidInput = true;
      } 
}
return Num;
}

long ControleDeSaisie::Verifierbool()
{
int Num;
bool gotValidInput = false;
 
while ( gotValidInput == false )
{	cin >> Num;
	if ((Num!=0)&&(Num!=1))
      {     cout << "Verifier le numéro saisie!!!!                                        *" << endl;
      }
	else
      {	gotValidInput = true;
      } 
}
return Num;
}

float ControleDeSaisie::Verifierfloat()
{
float Num;
bool gotValidInput = false;
 
while ( gotValidInput == false )
{     cin >> Num;
	if (cin.fail())
      {	cin.clear();
            cin.ignore();
            cout << "Verifier le numéro saisie!!!!                                        *" << endl;
      }
	else
      {	gotValidInput = true;
      } 
}
return Num;
}


string ControleDeSaisie::VerifierDate()
{
long aa;
long jj;
long mm;
ControleDeSaisie C;

do{	cout<<"Entrer l'année                                                 *"<<endl;
	aa=C.Verifierlong();
}while(aa<1900);

do{	cout<<"Entrer le mois                                                 *"<<endl;
	 mm=C.Verifierlong();
}while(mm>12);

switch (mm)
{	case (1):
	case (3):
	case (5):
	case (7):
	case (8):
	case (10):
	case (12):
	{
	do {	cout<<"Entrer le jour                                                 *"<<endl;
		 jj=C.Verifierlong();
	}while(jj>31);
	break;
	}

	case (4):
	case (6):
	case (9):
	case (11):
	{
	do {	cout<<"Entrer le jour                                                 *"<<endl;
		 jj=C.Verifierlong();
	}while(jj>30);
	break;
	}

	case(2):
	{
	if (aa%4==0)
	{
		do{	cout<<"Entrer le jour                                                 *"<<endl;
			 jj=C.Verifierlong();
		}while(jj>29);
	}
	else
	{
		do{	cout<<"Entrer le jour                                                 *"<<endl;
			 jj=C.Verifierlong();
		}while(jj>28);
	}
	break;
	}
}
	string date;
	stringstream oss;
	oss<<jj<<"/"<<mm<<"/"<<aa;
	date=oss.str();
return date;
}


